package com.darksider.darkotlin.net.module

import android.util.Log
import com.darksider.darkotlin.settings.Settings.DEBUG
import dagger.Module
import dagger.Provides
import okhttp3.logging.HttpLoggingInterceptor
import javax.inject.Singleton

/**
 * User: yaodong(1126220529@qq.com)
 * Date: 2017-05-26
 * Time: 11:58
 * Description: httpLogInterceptor依赖模块
 * Update:
 */
@Module
class HttpLogInterceptorModule {
    @Singleton @Provides fun httpLogInterceptor(): HttpLoggingInterceptor {
        val httoLogInterceptor = HttpLoggingInterceptor {
            msg ->
            Log.d("OkHttp", msg)
        }
        if (DEBUG)
            httoLogInterceptor.level = HttpLoggingInterceptor.Level.BODY
        else
            httoLogInterceptor.level = HttpLoggingInterceptor.Level.NONE

        return httoLogInterceptor
    }
}